main(i,j)
{
	double n;
	for(gets(&i);~scanf("%d%d",&i,&j);printf("%d\n",(int)((n==(int)n)?n-1:n)))
		n=log(j)/log(i);
}
